package com.party.core.service.school.impl;

import com.google.common.base.Strings;
import com.party.common.paging.Page;
import com.party.core.dao.read.school.ScCourseReadDao;
import com.party.core.dao.write.school.ScCourseWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.school.ScCourse;
import com.party.core.service.school.IScCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Set;

@Service
public class ScCourseService implements IScCourseService {
    @Autowired
    private ScCourseReadDao courseReadDao;

    @Autowired
    private ScCourseWriteDao courseWriteDao;

    @Override
    public String insert(ScCourse scCourse) {
        BaseModel.preInsert(scCourse);
        if (courseWriteDao.insert(scCourse)) {
            return scCourse.getId();
        }
        return null;
    }

    @Override
    public boolean update(ScCourse scCourse) {
        scCourse.setUpdateDate(new Date());
        return courseWriteDao.update(scCourse);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        if (Strings.isNullOrEmpty(id)) {
            return false;
        }
        return courseWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public ScCourse get(String id) {
        if (Strings.isNullOrEmpty(id)) {
            return null;
        }
        return courseReadDao.get(id);
    }

    @Override
    public List<ScCourse> listPage(ScCourse scCourse, Page page) {
        return courseReadDao.listPage(scCourse, page);
    }

    @Override
    public List<ScCourse> list(ScCourse scCourse) {
        return courseReadDao.listPage(scCourse, null);
    }

    @Override
    public List<ScCourse> batchList(Set<String> ids, ScCourse scCourse, Page page) {
        return null;
    }
}
